<!--
 * @Descripttion: 
 * @version: 
 * @Author: siebe
 * @Date: 2022-02-18 15:45:45
 * @LastEditors: siebe
 * @LastEditTime: 2022-02-20 11:57:46
-->
{include file="public/header" /}
<div class="header">
	<span>部门列表</span>
	<button type="button" class="layui-btn layui-btn-sm" onclick="add()">
		<i class="layui-icon layui-icon-add-1"></i>添加
	</button>
	<div></div>
</div>
<table class="layui-table">
	<thead>
	<tr>
		<th>ID</th>
		<th>部门名</th>
		<th>创建日期</th>
        <th>状态</th>
		<th>操作</th>
	</tr>
	</thead>
	<tbody>
	{volist name="lists" id="vo"}
	<tr>
		<td>{$vo.id}</td>
        <td>{$vo.name}</td>
		<td>{$vo.create_time | date='Y-m-d H:i'}</td>
		<td>
			{if ($vo.status == 1) }
			开启
			{else /}
			关闭
			{/if}
		</td>
		<td>
			<button type="button" class="layui-btn layui-btn-sm layui-btn-normal" onclick="edit({$vo.id})">
				<i class="layui-icon">&#xe642;</i>编辑
			</button>
			<button type="button" class="layui-btn layui-btn-sm layui-btn-danger" onclick="del({$vo.id})">
				<i class="layui-icon">&#xe640;</i>删除
			</button>
		</td>
	</tr>
	{/volist}
	</tbody>
</table>
<script type="text/javascript">
	layui.use(['layer'],function(){
		$ = layui.jquery;
	})
	function add() {
			layer.open({
				type: 2,
				title: '添加',
				shade: 0.3,
				area: ['550px', '550px'],
				content: '{$config.path}group/add'
			})
		}
		function edit(id) {
			layer.open({
				type: 2,
				title: '修改',
				shade: 0.3,
				area: ['550px', '550px'],
				content: '{$config.path}group/edit?id=' + id
			})
		}
		function del(id) {
			layer.confirm('您确定要删除吗？', {
				icon: 3,
				btn: ['确定', '取消']
			}, function () {
				$.get('{$config.path}group/delete?id=' + id, function (res) {
					if (res.error_code == 0) {
						layer.msg(res.msg, { 'icon': 1 });
						setTimeout(function () {
							window.location.reload();
						}, 1000);
					} else {
						layer.msg(res.msg, { 'icon': 2 });
					}
				}, 'json').error(function (res) {
					layer.msg(res.responseJSON.msg, { 'icon': 2 });
				});
			})
		}
</script>
</body>
</html>